import practice
import json_practice
import json
import datetime
import wx
import os
from http_rest_client import ReachOutHttpClient
from CreateCharityDialog import CreateCharityDialog
# import the REST library

client = ReachOutHttpClient()
print client.listCharities()

#charity = client.getCharityByName("PlanetGranite?")

#client.createCharity(json_practice.c)
#client.createTopic(json_practice.t)
#client.createComment(json_practice.c)
#client.getTopicByName("Climbing")
#client.getTopicDetails("Climbing")
#client.subscribe(json_practice.s)
#class MainWindow(wx.Frame):
#    def __init__(self, parent, title):
#        client = ReachOutHttpClient()
#
#        # A "-1" in the size parameter instructs wxWidgets to use the default size.
#        # In this case, we select 200px width and the default height.
#        wx.Frame.__init__(self, parent, title=title, size=(200,-1))
#        
#        self.CreateStatusBar() # A Statusbar in the bottom of the window
#
#        text_font = wx.Font(15, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Arial')
#        # Setting up the menu.
##        filemenu= wx.Menu()
##        menuOpen = filemenu.Append(wx.ID_OPEN, "&Open"," Open a file to edit")
##        menuAbout= filemenu.Append(wx.ID_ABOUT, "&About"," Information about this program")
##        menuExit = filemenu.Append(wx.ID_EXIT,"E&xit"," Terminate the program")
#
#        # Creating the menubar.
##        menuBar = wx.MenuBar()
##        menuBar.Append(filemenu,"&File") # Adding the "filemenu" to the MenuBar
##        self.SetMenuBar(menuBar)  # Adding the MenuBar to the Frame content.
#
#        # Events.
##        self.Bind(wx.EVT_MENU, self.OnOpen, menuOpen)
##        self.Bind(wx.EVT_MENU, self.OnExit, menuExit)
##        self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout)
#        
#        """ Connection Setup """
#        connectionPanel = wx.Panel(self)
#        connectionSizer = wx.BoxSizer(wx.HORIZONTAL)
#
#        hostText = wx.StaticText(connectionPanel, label = "Host: ", style = wx.ALIGN_LEFT)
#        portText = wx.StaticText(connectionPanel, label = "Port: ", style = wx.ALIGN_LEFT)
#        hostText.SetFont(text_font)
#        portText.SetFont(text_font)
#        hostField = wx.TextCtrl(connectionPanel)
#        portField = wx.TextCtrl(connectionPanel)
#        button = wx.Button(connectionPanel, -1, "Set Connection")
#        
#        connectionSizer.Add(hostText)
#        connectionSizer.Add(hostField)
#        connectionSizer.AddSpacer(20)
#        connectionSizer.Add(portText)
#        connectionSizer.Add(portField)
#        connectionSizer.AddSpacer(20)
#        connectionSizer.Add(button)
#        connectionPanel.SetSizer(connectionSizer)
#        
#        button.Bind(wx.EVT_BUTTON, self.setRootURL)
#        
#        """ Menu Setup """
#        menuPanel = wx.Panel(self)
#        displayText = wx.TextCtrl(self)
#        
#        controlSizer = wx.BoxSizer(wx.HORIZONTAL)
#        
#        controlSizer.Add(menuPanel, 0, wx.EXPAND)
#        controlSizer.Add(displayText, 1, wx.EXPAND)
#        
#        
#        menuSizer = wx.BoxSizer(wx.VERTICAL)
#    
#        charityTitle = wx.StaticText(menuPanel, label = "Charity", style = wx.ALIGN_LEFT)
#        charityTitle.SetFont(text_font)
#        discussionTitle = wx.StaticText(menuPanel, label = "Discussion", style = wx.ALIGN_LEFT)
#        discussionTitle.SetFont(text_font)
#        createCharityB = wx.Button(menuPanel, -1, "Create Charity", size=wx.Size(125,25))
#        listCharitiesB = wx.Button(menuPanel, -1, "List Charities", size=wx.Size(125,25))
#        getCharityByNameB = wx.Button(menuPanel, -1, "Charity Details", size=wx.Size(125,25))
#        donateCharityB = wx.Button(menuPanel, -1, "Donate to Charity", size=wx.Size(125,25))
#        
#        createTopicB = wx.Button(menuPanel, -1, "Create Topic", size=wx.Size(125,25))
#        listTopicsB = wx.Button(menuPanel, -1, "List Topics", size=wx.Size(125,25))
#        createCommentB = wx.Button(menuPanel, -1, "Create Comment", size=wx.Size(125,25))
#        getTopicByNameB = wx.Button(menuPanel, -1, "Get Topic By Name", size=wx.Size(125,25))
#        getTopicDetailsB = wx.Button(menuPanel, -1, "Get Topic Details", size=wx.Size(125,25))
#        line = wx.StaticLine(menuPanel)
#        line2 = wx.StaticLine(menuPanel)
#        
#        menuSizer.Add(charityTitle)
#        menuSizer.Add(line, flag = wx.EXPAND)
#        menuSizer.Add(createCharityB)
#        menuSizer.Add(listCharitiesB)
#        menuSizer.Add(getCharityByNameB)
#        menuSizer.Add(donateCharityB)
#        menuSizer.AddSpacer(20)
#
#        menuSizer.Add(discussionTitle)
#        menuSizer.Add(line2, flag = wx.EXPAND)
#        menuSizer.Add(createTopicB)
#        menuSizer.Add(listTopicsB)
#        menuSizer.Add(createCommentB)
#        menuSizer.Add(getTopicByNameB)
#        menuSizer.Add(getTopicDetailsB)
#        
#        menuPanel.SetSizer(menuSizer)
#
#        # Use some sizers to see layout options
#        connLine = wx.StaticLine(self)
#        mainSizer = wx.BoxSizer(wx.VERTICAL)
#        mainSizer.Add(connectionPanel, 0, wx.EXPAND)
#        mainSizer.Add(connLine, 0, wx.EXPAND)
#        mainSizer.Add(controlSizer, 1, wx.EXPAND)
# 
#
#        """ Button Event Bindings """
#        
#        createCharityB.Bind(wx.EVT_BUTTON, self.createCharity)
#
#        #Layout sizers
#        self.SetSizer(mainSizer)
#        self.SetAutoLayout(1)
#        mainSizer.Fit(self)
#        self.Centre()
#        self.Show()
#        
#    def setRootURL(self,e):
#        rootURL = "http://" + self.hostField.GetValue() + ":" + self.portField.GetValue()  + "/ReachOut/rest/community"
#        client.setRootURL(rootURL)
#
#    def createCharity(self,e):
#        """ Open a file"""
#        dlg = CreateCharityDialog(self)
##        dlg = wx.FileDialog(self, "Choose a file", self.dirname, "", "*.*", wx.OPEN)
#        if dlg.ShowModal() == wx.ID_OK:
#            self.filename = dlg.GetFilename()
#            self.dirname = dlg.GetDirectory()
#            f = open(os.path.join(self.dirname, self.filename), 'r')
#            self.control.SetValue(f.read())
#            f.close()
#        dlg.Destroy()
#
#app = wx.App(False)
#frame = MainWindow(None, "Reach Out Client")
#app.MainLoop()
